//
//  NewsCell.swift
//  SCA
//
//  Created by tjun on 2025/9/3.
//

import UIKit
import SnapKit


class NewsCell: BaseTableViewCell {
    
    var model: NewsModel! {
        didSet {
            titleLabel.text = model.title
            contentLabel.attributedText = model.attributedText
        }
    }
    
    private let titleLabel = UILabel(font: UIFontMediumMake(16), textColor: .systemBlue)
    private let contentLabel = UILabel()

    override func setSubView() {
        super.setSubView()
        
        
        self.backgroundColor = AppStyle.color.background

        selectionStyle = .none
        
        titleLabel.addTo(contentView)
        titleLabel.numberOfLines = 0
        titleLabel.snp.makeConstraints { make in
            make.left.right.equalToSuperview().inset(16)
            make.top.equalToSuperview().inset(16)
        }
        
        contentLabel.addTo(contentView)
        contentLabel.numberOfLines = 0
        contentLabel.snp.makeConstraints { make in
            make.left.right.equalTo(titleLabel)
            make.top.equalTo(titleLabel.snp.bottom).offset(8)
        }
        
        let lineView = UIView().addTo(contentView)
        lineView.backgroundColor = UIColor.gray.withAlphaComponent(0.2)
        lineView.snp.makeConstraints { make in
            make.left.right.equalTo(contentLabel)
            make.top.equalTo(contentLabel.snp.bottom).offset(16)
            make.bottom.equalToSuperview()
            make.height.equalTo(1)
        }
    }

}
